package com.ruoyi.ucar.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.ruoyi.ucar.domain.TCarouselImage;
import com.ruoyi.ucar.domain.po.CarouselImageDetailQueryPo;
import com.ruoyi.ucar.domain.po.CarouselImageListPo;
import com.ruoyi.ucar.domain.po.CarouselImageMobileListPo;
import com.ruoyi.ucar.moreq.CarouselImageDetailQueryMoReq;
import com.ruoyi.ucar.moreq.CarouselImageListQueryMoReq;
import com.ruoyi.ucar.moreq.CarouselImageMobileListQueryMoReq;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;

/**
 * 轮播图主Mapper接口
 * 
 * @author sungangbin
 * @date 2025-05-13
 */
@Mapper
public interface TCarouselImageMapper extends BaseMapper<TCarouselImage>
{
    /**
     * 查询轮播图主
     * 
     * @param id 轮播图主主键
     * @return 轮播图主
     */
    public TCarouselImage selectTCarouselImageById(Long id);

    /**
     * 查询轮播图主列表
     * 
     * @param tCarouselImage 轮播图主
     * @return 轮播图主集合
     */
    public List<TCarouselImage> selectTCarouselImageList(TCarouselImage tCarouselImage);

    /**
     * 新增轮播图主
     * 
     * @param tCarouselImage 轮播图主
     * @return 结果
     */
    public int insertTCarouselImage(TCarouselImage tCarouselImage);

    /**
     * 修改轮播图主
     * 
     * @param tCarouselImage 轮播图主
     * @return 结果
     */
    public int updateTCarouselImage(TCarouselImage tCarouselImage);

    /**
     * 删除轮播图主
     * 
     * @param id 轮播图主主键
     * @return 结果
     */
    public int deleteTCarouselImageById(Long id);

    /**
     * 批量删除轮播图主
     * 
     * @param ids 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteTCarouselImageByIds(Long[] ids);

    public int deleteTCarouselImageByUuids(@Param("deleteFlag") Long deleteFlag,@Param("carouselImageUuids") String[] carouselImageUuids);

    public int deleteTCarouselImageByids(@Param("deleteFlag") Long deleteFlag,@Param("ids") Long[] ids);

    @Select("<script>" +
            "SELECT " +
            "  tc.id as id, " +
            "  tc.carousel_image_title as carouselImageTitle, " +
            "  tc.carousel_image_uuid as carouselImageUuid, " +
            "  tc.status as  status, " +
            "  tc.remark as remark, " +
            "  tc.upload_datetime as uploadDatetime, " +
            "  tc.file_main_uuid as fileMainUuid, " +
            "  fd.file_url as fileUrl " +
            "FROM " +
            "  t_carousel_image tc " +
            "  LEFT JOIN sys_file_main fm on tc.file_main_uuid=fm.file_main_uuid " +
            "  LEFT JOIN sys_file_data fd ON fm.file_main_uuid = fd.file_main_uuid " +
            "<where>" +
            "   <if test='queryParams.deleteFlag != null'>" +
            "       AND (tc.delete_flag = #{queryParams.deleteFlag} " +
            "       AND fm.delete_flag = #{queryParams.deleteFlag} " +
            "       AND fd.delete_flag = #{queryParams.deleteFlag}) " +
            "   </if>" +
            "   <if test='queryParams.status != null'> AND tc.status = #{queryParams.status} </if>" +
            "</where>" +
            "</script>")
    public List<CarouselImageMobileListPo> carouselImageMobileListQuery(@Param("queryParams") CarouselImageMobileListQueryMoReq carouselImageMobileListQueryMoReq);


    @Select("<script>" +
            "SELECT " +
            "  tc.id as id, " +
            "  tc.carousel_image_title as carouselImageTitle, " +
            "  tc.carousel_image_uuid as carouselImageUuid, " +
            "  tc.status as  status, " +
            "  tc.remark as remark, " +
            "  tc.upload_datetime as uploadDatetime, " +
            "  tc.file_main_uuid as fileMainUuid, " +
            "  fd.file_url as fileUrl " +
            "FROM " +
            "  t_carousel_image tc " +
            "  LEFT JOIN sys_file_main fm on tc.file_main_uuid=fm.file_main_uuid " +
            "  LEFT JOIN sys_file_data fd ON fm.file_main_uuid = fd.file_main_uuid " +
            "<where>" +
            "   <if test='queryParams.carouselImageTitle != null and queryParams.carouselImageTitle != \"\"'>AND tc.carousel_image_title LIKE CONCAT('%',#{queryParams.carouselImageTitle},'%')</if>" +
            "   <if test='queryParams.deleteFlag != null'>" +
            "       AND (tc.delete_flag = #{queryParams.deleteFlag} " +
            "       AND fm.delete_flag = #{queryParams.deleteFlag} " +
            "       AND fd.delete_flag = #{queryParams.deleteFlag}) " +
            "   </if>" +
            "   <if test='queryParams.status != null'> AND tc.status = #{queryParams.status} </if>" +
            "   <if test='queryParams.uploadBeginDate != null and queryParams.uploadEndDate != null'> AND tc.upload_datetime &gt;= #{queryParams.uploadBeginDate} AND tc.upload_datetime &lt;= #{queryParams.uploadEndDate} </if>" +
            "</where>" +
            "</script>")
    public IPage<CarouselImageListPo> carouselImageListQueryPage(IPage<CarouselImageListPo> page, @Param("queryParams") CarouselImageListQueryMoReq carouselImageListQueryMoReq);


    @Select("<script>" +
            "SELECT " +
            "  tc.id as id, " +
            "  tc.carousel_image_title as carouselImageTitle, " +
            "  tc.carousel_image_uuid as carouselImageUuid, " +
            "  tc.status as  status, " +
            "  tc.remark as remark, " +
            "  tc.upload_datetime as uploadDatetime, " +
            "  tc.file_main_uuid as fileMainUuid, " +
            "  fd.file_url as fileUrl " +
            "FROM " +
            "  t_carousel_image tc " +
            "  LEFT JOIN sys_file_main fm on tc.file_main_uuid=fm.file_main_uuid " +
            "  LEFT JOIN sys_file_data fd ON fm.file_main_uuid = fd.file_main_uuid " +
            "<where>" +
            "   <if test='queryParams.deleteFlag != null'>" +
            "       AND (tc.delete_flag = #{queryParams.deleteFlag} " +
            "       AND fm.delete_flag = #{queryParams.deleteFlag} " +
            "       AND fd.delete_flag = #{queryParams.deleteFlag}) " +
            "   </if>" +
            "   <if test='queryParams.id != null'> AND tc.id = #{queryParams.id} </if>" +
            "   <if test='queryParams.carouselImageUuid != null'> AND tc.carousel_image_uuid = #{queryParams.carouselImageUuid} </if>" +
            "</where>" +
            "</script>")
    public List<CarouselImageDetailQueryPo> carouselImageDetailQuery(@Param("queryParams") CarouselImageDetailQueryMoReq carouselImageDetailQueryMoReq);


}
